<template>
	<view class="content" v-cloak>
		  <view class="item-top">
			  <image class='top-img' :src="avatar || '../../static/image/bg_img.png'">
			  <view class="item-conent">
				<view class="item-tops">
					<view>{{nickname}}</view>
				</view>
			  </view>
		  </view>
		  <view class="padding flex flex-direction" style="margin-top: 30upx;">
		  	<button class="cu-btn bg-grey lg" v-if="up.status != 2" @click="agreed">同意</button>
			<button class="cu-btn bg-grey lg juj" v-if="up.status != 2" @click="refused">拒绝</button>
			<button class="cu-btn bg-grey lg" v-if="up.status == 2" @click="xiaoxi">发送消息</button>
		  </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status:1,
				id:''
			}
		},
		onShow() {
			this.$msgchat.initwork();
		},
		onLoad(options) {
			this.id = options.id
			this.initDat();
		},
		methods: {
			//初始数据
			initDat(){
				this.$common.requests('/api/friend/getfriendinfo',{id: this.id}).then(res => {
					if(res.data.code == 1){
						this.nickname = res.data.data.nickname;
						if(res.data.data.avatar!=''){
							this.avatar = this.$common.baseUrl + res.data.data.avatar;
						}
					}
				})
			},
			SwitchA(e) {
				this.switchA = e.detail.value ;
				var obj = {
					id : this.id
				}
				if(this.switchA == true){
					this.$common.requests('/api/black/lahei', obj).then(res => {
					})
				}else if(this.switchA == false){
					this.$common.requests('/api/black/nohei', obj).then(res => {
					})
				}
			},
			dianji(){
				this.status=2;
			},
			chang(data){
				if (data.detail.value==""){
					return 
				}else{
					 this.remarks = data.detail.value;
				}	
			},
			xiaoxi(){
				uni.navigateTo({
					url:'../HM-chat/HM-chat?friend_id='+this.up.friend_id+'&nickname='+this.up.userinfo.nickname
				})
			},
			//同意
			agreed(){
				this.$common.requests('/api/Friend_add/okadd',{id:this.up.id,remarks:this.remarks}).then(res => {
					uni.navigateTo({
						url: '../addFriend/addFriend' 
					});
				})
			},
			//拒绝
			refused(){
				this.$common.requests('/api/Friend_add/noadd',{id: this.up.id}).then(res => {
					this.$api.msg(res.data.msg);
					this.status = 3;
				})
			}
		}
	}
</script>

<style >
			
			 page{
				 height: 100vh;
				 background: $uni-color-bei;
			 }
	          .myco{
	            color: #333!important;
	          }
	          .content{
	            width: 100%;
	            margin: 0px;
	            color: #333;
	          }
			  .lg{
				  background: $uni-bt-color;
			  }
	          .item-top{
	            width: 100%;
	            display: flex;
	            justify-content: flex-start;
	            align-items: center;
	            background: #fff;
	            margin-top: 0.7rem;
	            padding: 0.7rem 0 0.7rem 1rem;
	          }
			  .juj{
				  background: red;
				  margin-top: 40upx;
			  }
	          .item-tops{
	            width: 100%;
	            display: flex;
	            justify-content: flex-start;
	            align-items: center;
	            color: #333;
	            font-weight: bold;
	          }
	          .item-conent{
	            margin-left: 0.7rem;
	            height: 2.8rem;
	            display: flex;
	            flex-direction: column;
	            justify-content: space-between;
	          }
	          .top-img{
	            width: 3.5rem;
				height: 3.5rem;
	            border-radius: 50%;
	          }
	          .bot-img{
	            width: 0.7rem;
				height: 0.7rem;
	            margin-left: 6px;
	          }
	          .bot-text{
	            color: blue;
	            font-size: 16px;
	          }
	          .huitext{
	            color: #999797;
	            margin-left: 1.5rem;
	          }
	          .my-inner{
	            width: 95%;
	            display: flex;
	            justify-content: space-between;
	          }
	          .mybut{
	            width: 88%;
	            margin: 0 auto;
	            background: #03a9f4;
	            color: #fff;
	            font-size: 21px;
	            margin-top: 1rem;
	            max-height: 45px;
	            line-height: 45px;
	          }
</style>
